package controllers

import "github.com/astaxie/beego"

type ErrorController struct {
	beego.Controller
}

func (c *ErrorController) Error404() {
	if c.Ctx.Request.Header.Get("x-requested-with") == "XMLHttpRequest" {
		c.EnableRender = false
		c.ServeJSON()
	} else {
		c.Data["content"] = "page not found"
		c.TplName = "404.tpl"
	}
}

func (c *ErrorController) Error501() {
	c.Data["content"] = "server error"
	c.TplName = "501.tpl"
}

func (c *ErrorController) ErrorDb() {
	c.Data["content"] = "database is now down"
	c.TplName = "dberror.tpl"
}
